﻿package mortal.game.view.copy.QuestionCopy.item
{
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class QuestionCopyIcon extends ActionBaseIcon
    {
        protected var _leftTime:SecTimerView;
        private var _textF:GTextFiled;
        public var leftSecond:int = -1;
        private static var _instance:QuestionCopyIcon;

        public function QuestionCopyIcon()
        {
            super(ResFileConst.QuestionIcon);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.name = "QuestionCopyIcon";
            this._leftTime = UIFactory.secTimeView("mm:ss", 0, 50, 48, 20, this, GlobalStyle.textFormatHong.center());
            this._leftTime.timeOutHandler = this.timeCompl;
            this._leftTime.visible = false;
            this._textF = UIFactory.gTextField("" + Language.getString(70949), 0, 20, 80, 20);
            var _loc_1:Boolean = false;
            this._textF.mouseEnabled = false;
            this._textF.selectable = _loc_1;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this.name = "";
            this._leftTime.dispose(param1);
            this._leftTime = null;
            this._textF.dispose(param1);
            this._textF = null;
            return;
        }// end function

        override protected function timeOutCaller() : void
        {
            this.setLeftTimeAndState(0, 1);
            return;
        }// end function

        private function timeCompl() : void
        {
            this._leftTime.stop();
            this._leftTime.visible = false;
            return;
        }// end function

        public function updateOpenDt(param1:Date, param2:int) : void
        {
            var _loc_3:* = ClockManager.instance.nowDate;
            var _loc_4:* = (param1.time - _loc_3.time) / 1000;
            this.leftSecond = _loc_4;
            this.setLeftTimeAndState(_loc_4, param2);
            if (_loc_4 > 0)
            {
                this._leftTime.setLeftTime(_loc_4);
            }
            return;
        }// end function

        override protected function clickHandler(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CopyQuestionOpenEnter));
            return;
        }// end function

        public function get sectimerView() : SecTimerView
        {
            return this._leftTime;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

        public static function get instance() : QuestionCopyIcon
        {
            if (!_instance)
            {
                _instance = new QuestionCopyIcon;
            }
            return _instance;
        }// end function

    }
}
